﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace aaaa
{
    public partial class BJAdd : Form
    {
        public BJAdd()
        {
            InitializeComponent();
        }
          private void BJAdd_Load(object sender, EventArgs e)
        {
            string sql = "select xbname from XBtest";
            SqlOperate onj = new SqlOperate();
            SqlDataReader read = onj.getDataReader(sql);
            while (read.Read())
            {
                comboBox1.Items.Add(read.GetValue(0).ToString());
            }
            comboBox1.SelectedIndex = 0;

            string sql1 = "select zyname from ZYtest";
            SqlOperate onj1 = new SqlOperate();
            SqlDataReader read1 = onj1.getDataReader(sql1);
            while (read1.Read())
            {
                comboBox2.Items.Add(read1.GetValue(0).ToString());
            }
            comboBox2.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = "insert into classtest(bjid,bjname,bjteacher,bjcallnum,zyname,xbname) values ('" + textBox4.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + comboBox1.Text + "','" + comboBox2.Text + "')";
            SqlOperate obj = new SqlOperate();
            int i = obj.getIUD(sql);
            if (i > 0)
            { MessageBox.Show("添加记录成功！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
            else
            { MessageBox.Show("添加记录失败！", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

      
    }
}
